<form name=form1 method=post action="1.html?action=add">

来源:百度知道 编辑:UC知道 时间:2024/05/19 19:36:31
别一个页面用javascript接收传过来的值,怎么接收?
请高手详细指点,万分感谢!

html之间无法用POST传值
post的值是附加在http请求的头部的.只有在服务器端才能获得其值.

但是可以通过GET传值 即URL传值
改用Get方式,通过URL传值

如1.html?action=add

然后通过js获得得变量action的值

<SCRIPT LANGUAGE=JavaScript>
<!--

alert( GetQueryString("action"));

function GetQueryString(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r!=null) return unescape(r[2]); return null;
}
//-->
</SCRIPT>